<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/23
 * Time: 14:41
 */

namespace Common\Model;


use Think\Model;

class DutyArrangeModel extends Model
{
    protected $_tableName = 'duty_arrange';

    public function update($data){
        if(!isset($data['duty_type_id']) || !isset($data['duty_date'])){
            return false;
        }

        $where['duty_type_id'] = $data['duty_type_id'];
        $where['duty_date'] = $data['duty_date'];
        $record = $this->where($where)->find();
        if($record){
            $this->where($where)->save($data);
            return $record['duty_arrange_id'];
        }else{
            $data = $this->create($data);
            if($data){
                $id = $this->add();
                if(!$id){
                    return false;
                }else{
                    return $id;
                }
            }else{
                return false;
            }
        }

    }

}